/* 
  路由拦截对象
*/
export const routerInterceptor = {
  //版本说明
  '/private_version_menu': (to, form, next, store) => {
    let url = '';
    if (location.href.includes('cloud-')) {
      url = `https://${location.host}/wiki/c/releaseLatest`;
    } else {
      url = 'https://cloud-as.ruijienetworks.com/wiki/c/releaseLatest';
    }
    window.open(url);

    const { layout } = form.meta;
    store.commit('Layout/SET_LAYOUT', layout);
    next(form.path);
  },

  '/private_quick_menu': (to, form, next, store) => {
    let url = '';
    if (location.href.includes('cloud-')) {
      url = `https://${location.host}/wiki/article-quickStartGuide-1`;
    } else {
      url =
        'https://cloud-as.ruijienetworks.com/wiki/article-quickStartGuide-1';
    }
    window.open(url);

    const { layout } = form.meta;
    store.commit('Layout/SET_LAYOUT', layout);
    next(form.path);
  },

  '/private_userguide_menu': (to, form, next, store) => {
    let url = '';
    if (location.href.includes('cloud-')) {
      url = `https://${location.host}/wiki/c/User_Guide__Montoring__Dsahsbord`;
    } else {
      url =
        'https://cloud-as.ruijienetworks.com/wiki/c/User_Guide__Montoring__Dsahsbord';
    }
    window.open(url);

    const { layout } = form.meta;
    store.commit('Layout/SET_LAYOUT', layout);
    next(form.path);
  },

  '/private_supportmodel_menu': (to, form, next, store) => {
    let url = '';
    if (location.href.includes('cloud-')) {
      url = `https://${location.host}/wiki/c/Other__Operation_Tip__Supported_Models`;
    } else {
      url =
        'https://cloud-as.ruijienetworks.com/wiki/c/Other__Operation_Tip__Supported_Models';
    }
    window.open(url);

    const { layout } = form.meta;
    store.commit('Layout/SET_LAYOUT', layout);
    next(form.path);
  },
  //云地勘
  '/lab_aiHeatMap_menu': (to, form, next, store) => {
    window.open('/design/#/home?from=macc_site');
    const { layout } = form.meta;
    store.commit('Layout/SET_LAYOUT', layout);
    next(form.path);
  },
  // {
  //   path: '/private_version_menu',
  //   redirect: (to) => {
  //     let url = '';
  //     if (location.href.includes('cloud-')) {
  //       url = `https://${location.host}/wiki/c/releaseLatest`;
  //     } else {
  //       url = 'https://cloud-as.ruijienetworks.com/wiki/c/releaseLatest';
  //     }

  //     return { redirect: window.open(url) };
  //   },
  // },
  // {
  //   path: '/private_quick_menu',
  //   redirect: (to) => {
  //     let url = '';
  //     if (location.href.includes('cloud-')) {
  //       url = `https://${location.host}/wiki/article-quickStartGuide-1`;
  //     } else {
  //       url =
  //         'https://cloud-as.ruijienetworks.com/wiki/article-quickStartGuide-1';
  //     }

  //     return { redirect: window.open(url) };
  //   },
  // },
  // {
  //   path: '/private_userguide_menu',
  //   redirect: (to) => {
  //     let url = '';
  //     if (location.href.includes('cloud-')) {
  //       url = `https://${location.host}/wiki/c/User_Guide__Montoring__Dsahsbord`;
  //     } else {
  //       url =
  //         'https://cloud-as.ruijienetworks.com/wiki/c/User_Guide__Montoring__Dsahsbord';
  //     }

  //     return { redirect: window.open(url) };
  //   },
  // },
  // {
  //   path: '/private_supportmodel_menu',
  //   redirect: (to) => {
  //     let url = '';
  //     if (location.href.includes('cloud-')) {
  //       url = `https://${location.host}/wiki/c/Other__Operation_Tip__Supported_Models`;
  //     } else {
  //       url =
  //         'https://cloud-as.ruijienetworks.com/wiki/c/Other__Operation_Tip__Supported_Models';
  //     }

  //     return { redirect: window.open(url) };
  //   },
  // },
};

/**
 * 0项目账号不拦截菜单那
 */
export const project0NoInterceptor = [
  '/setting_contact_menu',
  '/private_theme_menu',
  '/private_accountsetting_menu',
  '/account_menu',
  '/',
  '/monitor_overview_global_menu',
  '/system_config_menu',
  '/lab_aiHeatMap_menu',
];
